<template>
	<!-- 个人中心模块 -->
	<view :style="colorStyle"
		  class="user-page">
		<!--    顶部悬浮-->
		<view :style="[mpHeaderStyle]"
			  class="mp-header">
			<view :style="{ height: statusBarHeight + 'px' }"
				  class="sys-head"></view>
			<view class="title">
				<!-- #ifdef MP-WEIXIN -->
				<text>个人中心</text>
				<!-- #endif -->
			</view>
		</view>
		<!--    悬浮占位-->
		<view :style="'height:' + (statusBarHeight + 43) + 'px'"></view>
		<template v-if="isObjectData(diyData)">
			<user-member :balanceStatus="balanceStatus"
						 :isScrolling="isScrolling"
						 :memberData="diyData.member"
						 :orderAdminData="orderAdminData"
						 :userInfo="userInfo"></user-member>
			<view class="tab-box">
				<view>
					<view v-for="(item, index) in tabOrderList"
						  :id="'id' + index"
						  :key="index"
						  :class="{ click: index == tabOrderIndex }"
						  :data-index="index"
						  class="longItem"
						  @click="changeTab(index)"> {{ item.name }} <view v-if="item.num > 0"
							  class="badge-box"></view>
					</view>
				</view>
				<!--        <u-tabs :list="tabOrderList" :current="tabOrderIndex" @change="changeTab"></u-tabs>-->
				<view class="flex-y-center text--w111-999"
					  @click="goOrderList">
					<text class="fs-26 lh-26rpx">查看全部</text>
					<text class="iconfont icon-ic_rightarrow fs-24"></text>
				</view>
			</view>
			<swiper :current="tabOrderIndex"
					class="swiper-box"
					style="height: 160upx;"
					@change="changeSwiper">
				<swiper-item>
					<user-order id="order0"
								:leaseType="1"
								:memberData="diyData.member"
								:orderAdminData="orderAdminData"
								:orderData="diyData.order"
								:orderMenu="orderMenu.lease"
								:userInfo="userInfo"></user-order>
				</swiper-item>
				<swiper-item>
					<user-order id="order1"
								:leaseType="2"
								:memberData="diyData.member"
								:orderAdminData="orderAdminData"
								:orderData="diyData.order"
								:orderMenu="orderMenu.mall"
								:userInfo="userInfo"></user-order>
				</swiper-item>
			</swiper>
			<!-- 补充资料 v-if="userInfo.certify_status!=1"-->
			<view v-if="showCompleteData"
				  class="data-tip"
				  @click="goUserData">
				<view class="l">
					<i class="iconfont icon-ic_camera"> </i>
					<view class="l-txt">
						<view class="l-1">请完善实名资料</view>
						<view class="l-2">认证身份信息，加快审核</view>
					</view>
				</view>
				<view class="r"> 去完善 </view>
			</view>
			<user-poster :posterData="diyData.poster"></user-poster>
			<view v-if="diyData.aliVip">
				<aliPayVip :dataConfig="diyData.aliVip"
						   type="user"></aliPayVip>
			</view>
			<user-menu :menuData="diyData.menu"></user-menu>
			<user-order-static v-if="isObjectData(orderAdminData) && orderAdminData.order.user_order"
							   :orderAdminData="orderAdminData.order"
							   :orderStaticData="diyData.orderStatic"></user-order-static>
			<user-mer-menu v-if="diyData.merMenu.list.length"
						   :merMenuData="diyData.merMenu"></user-mer-menu>
			<user-store-menu v-if="diyData.storeMenu.list.length"
							 :storeMenuData="diyData.storeMenu"></user-store-menu>
			<view v-if="false">
				<view class="copy_right pb-20">
					<template v-if="copyRightText">
						<image :src="copyRightImg"
							   class="copyRightImg"
							   mode="aspectFill"></image>
						<view class="copyRightText"> {{ copyRightText }} </view>
					</template>
					<image v-else
						   :src="copyRightImg"
						   class="support"
						   mode="aspectFill"></image>
				</view>
			</view>
		</template>
		<!-- 店员推广码 extension-->
		<view>
			<view v-show="isextension"
				  class="fixed-ct w-620 h-690 bg--w111-fff rd-24rpx ml-f310 mt-f400 z-1000"
				  @touchmove.stop.prevent>
				<view class="fs-32 text-#333 fw-500 mt-48 mb-48 text-center">店员推广码</view>
				<view class="acea-row row-center-wrapper">
					<!-- #ifdef MP -->
					<image :src="extension.code"
						   class="w-380 h-380"
						   @click="downloadCode"></image>
					<!-- #endif -->
					<!-- #ifndef MP -->
					<view class="acea-row row-center-wrapper"
						  @click="downloadCode">
						<w-qrcode id="hah"
								  :options="extension"
								  @generate="hello"></w-qrcode>
					</view>
					<!-- #endif -->
					<view class="fs-26 text--w111-999 mt-40 w-312 text-center">如遇到扫码失败，</view>
					<view class="fs-26 text--w111-999 mt-10 w-312 text-center">请将屏幕调至最亮重新扫码</view>
				</view>
				<view class="iconfont icon-ic_close1 text--w111-fff absolute fs-50 bottom-f100rpx left-50 ml-f25"
					  @click="closeCode"></view>
			</view>
			<view v-show="isextension"
				  class="fixed-lt bg-w111-000-s111-80 w-full h-full z-999"
				  @touchmove.stop.prevent></view>
			<ewcomerPop v-if="isComerGift"
						:comerGift="comerGift"
						@comerPop="comerPop"></ewcomerPop>
			<!-- #ifdef MP -->
			<editUserModal :isShow="editModal"
						   @closeEdit="closeEdit"
						   @editSuccess="editSuccess"></editUserModal>
			<!-- #endif -->
		</view>
		<pageFooter @newDataStatus="newDataStatus"></pageFooter>
		<chatModal ref="chatModal"></chatModal>
	</view>
</template>
<script>
import TopBar from "@/pages/user/components/topBar.vue"

let statusBarHeight = uni.getSystemInfoSync().statusBarHeight
import { storeCardApi } from "@/api/store.js"
import { newcomerGift } from "@/api/activity.js"
import { copyRight } from "@/api/api.js"
import {
	getMenuList,
	getUserInfo,
	setVisit,
	updateUserInfo,
	getRandCode,
	updateWechatInfo,
	getMenuData
} from "@/api/user.js"
import { wechatAuthV2, silenceAuth } from "@/api/public.js"
import { toLogin } from "@/libs/login.js"
import { mapState, mapGetters } from "vuex"
// #ifdef H5
import Auth from "@/libs/wechat"
// #endif
import { HTTP_REQUEST_URL } from "@/config/app"

const app = getApp()
import ewcomerPop from "@/components/ewcomerPop/index.vue"
import pageFooter from "@/components/pageFooter/index.vue"
import dayjs from "@/plugin/dayjs/dayjs.min.js"
import Routine from "@/libs/routine"
import colors from "@/mixins/color"
// #ifdef MP
import editUserModal from "@/components/eidtUserModal/index.vue"
// #endif
import userMember from "./components/member/index.vue"
import userOrder from "./components/order/index.vue"
import userOrderStatic from "./components/order_static/index.vue"
import userMenu from "./components/menus/index.vue"
import userMerMenu from "./components/merMenus/index.vue"
import userStoreMenu from "./components/storeMenus/index.vue"
import userPoster from "./components/poster/index.vue"
import { goodsType } from "@/tools/goods"
import { completeData } from "@/tools/user"
import aliPayVip from "@/pages/index/components/aliPayVip.vue"
import chatModal from "@/components/chatModal/index.vue"

export default {
	components: {
		chatModal,
		aliPayVip,
		TopBar,
		userMember,
		userOrder,
		userOrderStatic,
		userMenu,
		userMerMenu,
		userStoreMenu,
		userPoster,
		pageFooter,
		ewcomerPop,
		// #ifdef MP
		editUserModal
		// #endif
	},
	computed: {
		...mapGetters({
			cartNum: "cartNum",
			isLogin: "isLogin"
		}),
		titleStyle() {
			if (!this.diyData.member) return
			let style = {}
			if (this.diyData.member.style === 1) {
				style.fontColor = "#ffffff"
			}
			if (this.isScrolling) {
				style.fontColor = "#000000"
			}
			return style
		},
		mpHeaderStyle() {
			if (!this.diyData.member) return
			// 根据不同的风格设置不同的背景
			let style = {}
			switch (this.diyData.member.style) {
				case 1:
					style.background = `var(--view-theme)`
					style.fontColor = `#fff !important`
					// uni.setNavigationBarColor({
					//   frontColor: '#ffffff',
					//   backgroundColor: '#ffffff00',
					// })
					break
				case 2:
					style.background = `rgba(245, 245, 245, 0.6)`
					break
				case 3:
					style.background = `rgba(245, 245, 245, 0.6)`
					break
				case 4:
					style.background = `rgba(245, 245, 245, 0.6)`
					break
				case 5:
					style.background = `url(${HTTP_REQUEST_URL}/statics/images/users/template4_bg.png) top`
					break
			}
			// && this.dataConfig.searchConfig.tabVal
			if (this.isScrolling) {
				style.background = `rgba(255, 255, 255, 0.6)`
				style.backdropFilter = `blur(10px)`
				// uni.setNavigationBarColor({
				//   frontColor: '#000',
				//   backgroundColor: '#ffffff00',
				// })
			}
			return style
		}
	},
	filters: {},
	mixins: [colors],
	provide() {
		return {
			tapQrCode: this.tapQrCode,
			bindPhone: this.bindPhone,
			intoPage: this.intoPage,
			goMenuPage: this.goMenuPage,
			getMenuData: this.getMenuData,
			goEdit: this.goEdit
		}
	},
	data() {
		return {
			showCompleteData: false,
			statusBarHeight: statusBarHeight,
			tabOrderList: [{
				name: "租赁订单",
				num: 0
			},
			{ name: "商城订单", num: 0 }
			],
			tabOrderIndex: 0,

			diyData: {},
			orderAdminData: {},
			// #ifdef MP
			getHeight: this.$util.getWXStatusHeight(),
			// #endif
			vipStatus: 0,
			stu: false,
			orderMenu: {
				mall: [{
					icon: "",
					title: "待付款",
					url: "/pages/goods/order_list/index?status=0"
				},
				{
					icon: "",
					title: "待发货",
					url: "/pages/goods/order_list/index?status=1"
				},
				{
					icon: "",
					title: "待收货",
					url: "/pages/goods/order_list/index?status=2"
				},
				{
					icon: "",
					title: "待评价",
					url: "/pages/goods/order_list/index?status=3"
				},
				{
					icon: "",
					title: "售后/退款",
					url: "/pages/users/user_return_list/index"
				}
				],
				lease: [{
					icon: "",
					title: "待审核",
					url: "/pages/goods/lease_order_list/index?status=0"
				},
				{
					icon: "",
					title: "交付中",
					url: "/pages/goods/lease_order_list/index?status=99"
				},
				{
					icon: "",
					title: "租用中",
					url: "/pages/goods/lease_order_list/index?status=3"
				},
				{
					icon: "",
					title: "逾期中",
					url: "/pages/goods/lease_order_list/index?status=34"
				},
				{
					icon: "",
					title: "已完成",
					url: "/pages/goods/lease_order_list/index?status=4"
				}
				]
			},
			imgUrls: [],
			orderStatusNum: {},
			userInfo: {},
			showStatus: 1,
			// #ifdef H5 || MP
			pageHeight: "100%",
			routineContact: 0,
			// #endif
			// #ifdef APP-PLUS
			pageHeight: app.globalData.windowHeight,
			// #endif
			// #ifdef H5
			isWeixin: Auth.isWeixin(),
			//#endif
			footerSee: false,
			member_style: 1,
			my_banner_status: 1,
			menu_status: 1,
			service_status: 1,
			newcomer_status: 1,
			isextension: false,
			extension: {
				code: "",
				size: 380, // 二维码大小
				level: 3, //等级 0～4
				bgColor: "#ffffff", //二维码背景色 默认白色
				color: ["#333333", "#333"] //边框颜色支持渐变色
			},
			imgHost: HTTP_REQUEST_URL,
			copyRightText: "",
			copyRightImg: "",
			giftPic: "",
			vip_type: 1,
			newcomer_style: 1,
			newList: [],
			newBg: "",
			comerGift: {},
			isComerGift: false,
			memberStatus: 0,
			balanceStatus: 0, // 余额是否展示
			editModal: false, // 编辑头像信息
			isScrolling: false,
			orderStyle: {
				1: ["icon-ic_daifukuan12", "icon-ic_daifahuo11", "icon-ic_daishouhuo1", "icon-ic_daipingjia1", "icon-ic_daituikuan1"],
				2: ["icon-ic_daifukuan2", "icon-ic_daifahuo2", "icon-ic_daishouhuo2", "icon-ic_daipingji2", "icon-ic_daituikuan2"],
				3: ["icon-ic_daifukuan", "icon-ic_daifahuo", "icon-ic_daishouhuo", "icon-ic_daipingjia", "icon-ic_daituikuan"]
			},
			codeImg: "",
			isFooter: false,
			pdHeight: 0
		}
	},
	created() {
		let that = this
		// #ifdef MP
		// 小程序静默授权
		if (!this.$store.getters.isLogin) {
			// Routine.getCode()
			//   .then(code => {
			//     Routine.silenceAuth(code).then(res => {
			//       this.onLoadFun();
			//     })
			//   })
			//   .catch(res => {
			//     uni.hideLoading();
			//   });
		}
		// #endif
		// #ifdef APP-PLUS
		that.$set(that, "pageHeight", app.globalData.windowHeight)
		// #endif
	},
	async onLoad(option) {
		if (this.isLogin) {
			// this.getNewcomerGift();
		}
		// #ifdef H5
		if (this.isLogin && Auth.isWeixin() && option.code) {
			try {
				let res = await updateWechatInfo({
					code: option.code
				})
				this.userInfo.nickname = res.data.nickname
				this.userInfo.avatar = res.data.avatar
				this.userInfo.is_complete = 1
			} catch (e) { }
		}
		// #endif
		this.colorData()
	},
	onReady() { },
	onShow() {
		if (!this.isLogin) {
			this.userInfo = {
				avatar: "/static/images/f.png",
				uid: "",
				loginTxt: "去登录"
			}
			// toLogin();
			// return;
		}
		if (this.cartNum > 0) {
			uni.setTabBarBadge({
				index: 3,
				text: this.cartNum > 99 ? "99+" : this.cartNum + ""
			})
		} else {
			uni.hideTabBarRedDot({
				index: 3
			})
		}
		this.copyRightText = uni.getStorageSync("copyNameInfo")
		this.copyRightImg = uni.getStorageSync("copyImageInfo")
		uni.removeStorageSync("form_type_cart")
		if (!this.copyRightText) {
			this.getCopyRight()
		}
		let that = this
		// #ifdef APP-PLUS
		uni.getSystemInfo({
			success: function (res) {
				that.pageHeight = res.windowHeight + "px"
			}
		})
		// #endif
		if (that.isLogin) {
			this.getUserInfo()
			this.setVisit()
			this.getMenuData()
		}
		this.getMyMenus()

		if (this.isFooter) {
			uni.hideTabBar()
		}
	},
	// #ifdef MP || APP-PLUS
	onPageScroll(e) {
		if (e.scrollTop > 50) {
			this.isScrolling = true
		} else if (e.scrollTop < 50) {
			this.isScrolling = false
		}
	},
	// #endif
	methods: {
		completeData,
		newDataStatus(val, num) {
			this.isFooter = val ? true : false
			this.pdHeight = num
		},
		goUserData() {
			uni.navigateTo({ url: "/pages/users/user_add_data/index" })
		},
		changeTab(index) {
			this.tabOrderIndex = index
			// #ifdef MP-WEIXIN
			// this.$nextTick(() => {
			//   // tab切换中swiper高度自适应内容高度
			//   uni.createSelectorQuery().select('order'+index).boundingClientRect(rect=>{
			//     console.log('打印该盒子的元素',rect.height);
			//     // console.log('打印swiperHeight的数值',this.swiperHeight);
			//   }).exec()
			// });
			// #endif
		},
		changeSwiper(e) {
			this.tabOrderIndex = e.detail.current
		},
		goOrderList() {
			let leaseType = this.tabOrderIndex === 0 ? 1 : 2
			if (goodsType[leaseType] === "lease") {
				this.intoPage(`/pages/goods/lease_order_list/index`)
			} else if (goodsType[leaseType] === "mall") {
				this.intoPage(`/pages/goods/order_list/index`)
			}
		},

		hello(res) {
			this.codeImg = res.img.tempFilePath
		},
		downloadCode() {
			let that = this
			// #ifdef H5
			var canvas = document.getElementById("hah").getElementsByTagName("canvas")
			var imgURL = canvas[0].toDataURL("image/png")
			var dlLink = document.createElement("a")
			dlLink.download = "店员推广码"
			dlLink.href = imgURL
			dlLink.dataset.downloadurl = ["image/png", dlLink.download, dlLink.href].join(":")
			document.body.appendChild(dlLink)
			dlLink.click()
			document.body.removeChild(dlLink)
			// #endif
			// #ifdef MP
			uni.downloadFile({
				url: that.extension.code, //仅为示例，并非真实的资源
				success: (res) => {
					if (res.statusCode === 200) {
						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success: function (res) {
								that.$util.Tips({
									title: "保存成功",
									icon: "success"
								})
							},
							fail: function (res) {
								console.log(res)
								that.$util.Tips({
									title: "保存失败"
								})
							}
						})
					}
				}
			})
			// #endif
			// #ifdef APP-PLUS
			uni.saveImageToPhotosAlbum({
				filePath: that.codeImg,
				success: function (res) {
					that.$util.Tips({
						title: "保存成功",
						icon: "success"
					})
				},
				fail: function (res) {
					that.$util.Tips({
						title: "保存失败"
					})
				}
			})
			// #endif
		},
		closeCode() {
			this.isextension = false
		},
		isObjectData(obj) {
			return Object.keys(obj).length !== 0
		},
		// #ifdef MP
		editSuccess() {
			this.editModal = false
			this.getUserInfo()
		},
		closeEdit() {
			this.editModal = false
		},
		// #endif
		getCopyRight() {
			copyRight()
				.then((res) => {
					let data = res.data
					if (!data.copyrightContext && !data.copyrightImage) {
						data.copyrightImage = "/static/images/support.png"
					}
					uni.setStorageSync("copyNameInfo", data.copyrightContext)
					uni.setStorageSync("copyImageInfo", data.copyrightImage)
					this.copyRightText = data.copyrightContext
					this.copyRightImg = data.copyrightImage
				})
				.catch((err) => {
					return this.$util.Tips({
						title: err.msg
					})
				})
		},
		// 查看订单
		intoPage(url) {
			if (this.isLogin) {
				if (["/pages/users/user_vip/index", "/pages/annex/vip_grade_active/index"].includes(url) && !this.userInfo.member_func_status) {
					this.$util.Tips({
						title: "会员卡功能暂未开启"
					})
				} else {
					this.$util.JumpPath(url)
				}
			} else {
				toLogin()
			}
		},
		// 编辑页面
		goEdit() {
			if (this.isLogin == false || !this.userInfo.uid) {
				toLogin("userLogin")
			} else {
				// #ifdef MP
				if (this.userInfo.is_default_avatar) {
					this.editModal = true
					return
				}
				// #endif
				uni.navigateTo({
					url: "/pages/users/user_set/index"
				})
			}
		},
		goDetail(item) {
			uni.navigateTo({
				url: `/pages/goods_details/index?id=${item.id}&fromPage='newVip'`
			})
		},
		comerPop() {
			this.isComerGift = false
		},
		getNewcomerGift() {
			if (uni.getStorageSync("newcomerGift")) {
				return (this.isComerGift = false)
			}
			newcomerGift()
				.then((res) => {
					this.comerGift = res.data
					if (Object.prototype.toString.call(this.comerGift) == "[object Object]") {
						if (res.data.coupon_count || res.data.product_count || res.data.register_give_money || res.data.first_order_discount || res.data.register_give_integral) {
							uni.setStorageSync("newcomerGift", true)
							this.isComerGift = true
						}
					}
				})
				.catch((err) => {
					return this.$util.Tips({
						title: err
					})
				})
		},
		tapQrCode() {
			uni.navigateTo({
				url: "/pages/users/user_member_code/index"
			})
		},
		getRoutineUserInfo(e) {
			updateUserInfo({
				userInfo: e.detail.userInfo
			})
				.then((res) => {
					this.getUserInfo()
					return this.$util.Tips("更新用户信息成功")
				})
				.catch((err) => {
					return this.$util.Tips(err)
				})
		},
		// 记录会员访问
		setVisit() {
			setVisit({
				url: "/pages/user/index"
			}).then((res) => { })
		},
		// 打开授权
		openAuto() {
			toLogin()
		},
		// 授权回调
		onLoadFun(e) {
			this.getUserInfo(e)
			this.getMyMenus()
			this.setVisit()
		},
		// 绑定手机
		bindPhone() {
			uni.navigateTo({
				url: "/pages/users/user_phone/index"
			})
		},
		// 获取行销数据
		getMenuData() {
			getMenuData().then((res) => {
				this.orderAdminData = res.data
			})
		},
		/**
		 * 获取个人用户信息
		 */
		getUserInfo() {
			let that = this
			getUserInfo().then(async (res) => {
				that.userInfo = res.data
				that.stu = res.data.svip_open
				that.balanceStatus = res.data.balance_func_status
				that.memberStatus = parseInt(res.data.member_func_status)
				that.vipStatus = res.data.vip_status
				that.$store.commit("SETUID", res.data.uid)
				that.$store.commit("UPDATE_USERINFO", res.data)
				that.orderMenu.mall.forEach((item, index) => {
					switch (item.title) {
						case "待付款":
							this.$set(item, "num", res.data.orderStatusNum.unpaid_count)
							break
						case "待发货":
							this.$set(item, "num", res.data.orderStatusNum.unshipped_count)
							break
						case "待收货":
							this.$set(item, "num", res.data.orderStatusNum.received_count)
							break
						case "待评价":
							this.$set(item, "num", res.data.orderStatusNum.evaluated_count)
							break
						case "售后/退款":
							this.$set(item, "num", res.data.orderStatusNum.refunding_count)
							break
					}
				})
				this.tabOrderList[1].num = res.data.orderStatusNum.order_count
				this.tabOrderList[0].num = res.data.leaseOrderStatusNum.order_count
				that.orderMenu.lease.forEach((item, index) => {
					switch (item.title) {
						case "待审核":
							this.$set(item, "num", res.data.leaseOrderStatusNum.unaudit_count)
							break
						case "交付中":
							this.$set(item, "num", res.data.leaseOrderStatusNum.delivery_count)
							break
						case "租用中":
							this.$set(item, "num", res.data.leaseOrderStatusNum.lease_count)
							break
						case "逾期中":
							this.$set(item, "num", res.data.leaseOrderStatusNum.overdue_count)
							break
						case "已完成":
							this.$set(item, "num", res.data.leaseOrderStatusNum.complete_count)
							break
					}
				})

				this.showCompleteData = await completeData(res.data)
			})
		},
		getMyMenus: function () {
			let that = this
			getMenuList().then((res) => {
				this.diyData = res.data.diy_data
				this.switchTab(this.diyData.order.style)
				this.my_banner_status = res.data.diy_data.my_banner_status
				this.menu_status = res.data.diy_data.menu_status
				this.service_status = res.data.diy_data.service_status
				this.vip_type = res.data.diy_data.vip_type
				this.newcomer_style = res.data.diy_data.newcomer_style
				this.newcomer_status = res.data.diy_data.newcomer_status
				this.imgUrls = res.data.routine_my_banner
				this.routineContact = Number(res.data.routine_contact_type)

				console.log(this.diyData.menu)

				// this.diyData.menu.list.push({
				// 	name: "门店申请",
				// 	pic: "https://qntuanchefu.tann.cc/attach/2025/08/db76e202508271159477977.png",
				// 	type: "1",
				// 	url: "/pages/users/store_application/store_application"
				// })
			})
		},
		switchTab(style) {
			this.orderMenu.mall.forEach((item, index) => {
				item.icon = this.orderStyle[style][index]
			})
			this.orderMenu.lease.forEach((item, index) => {
				item.icon = this.orderStyle[style][index]
			})
		},
		goMenuPage(url, name) {
			// 未登录：跳转离线客服 '/pages/extension/customer/index',客服中心

			// 打开客服弹窗
			if (url == "/pages/extension/customer_list/chat") {
				this.$refs.chatModal.open()
				return
			}

			if (url == "/pages/extension/news_list/index") {
				uni.navigateTo({
					url: url
				})
				return
			}


			if (!this.isLogin && ["/pages/extension/customer_list/chat"].includes(url)) {
				uni.navigateTo({
					url: "/pages/extension/customer_list/feedback"
				})
				return
			}
			if (!this.isLogin) {
				toLogin()
			}
			if (this.isLogin) {
				let arr = url.split("@APPID=")
				if (arr.length > 1) {
					//#ifdef MP
					uni.navigateToMiniProgram({
						appId: arr[arr.length - 1], // 此为生活缴费appid
						path: arr[0], // 此为生活缴费首页路径
						envVersion: "release",
						success: (res) => {
							console.log("打开成功", res)
						},
						fail: (err) => {
							console.log("sgdhgf", err)
						}
					})
					//#endif
					//#ifndef MP
					this.Tips({
						title: "h5与app端不支持跳转外部小程序"
					})
					//#endif
				} else {
					if (url == "/pages/extension/customer_list/chat" || url == "https://chat.crmeb.net/chat/mobile") {
						this.$util.getCustomer(this.userInfo)
					} else {
						if (url.indexOf("http") === -1) {
							// #ifdef H5
							if (name && name === "订单核销") {
								return (window.location.href = `${location.origin}${url}`)
							}
							// #endif
							// #ifdef MP
							if (url != "#" && url == "/pages/users/user_set/index") {
								uni.openSetting({
									success: function (res) { }
								})
							}
							// #endif

							if (url == "/pages/store_spread/index") {
								storeCardApi()
									.then((res) => {
										this.isextension = true
										this.$nextTick(function () {
											this.extension.code = res.data.url
										})
									})
									.catch((err) => {
										uni.hideLoading()
										this.$util.Tips({
											title: err
										})
									})
								return false
							}
							if (
								["/pages/goods_cate/goods_cate", "/pages/order_addcart/order_addcart", "/pages/user/index", "/pages/store_cate/store_cate", "/pages/index/index"].indexOf(url) == -1
							) {
								uni.navigateTo({
									url: url,
									fail: function (err) {
										uni.reLaunch({
											url: url
										})
									}
								})
							} else {
								uni.reLaunch({
									url: url
								})
							}
						} else {
							// #ifdef H5
							this.$util.JumpPath(url)
							// #endif
							// #ifndef H5
							uni.navigateTo({
								url: `/pages/annex/web_view/index?url=${url}`
							})
							// #endif
						}
					}
				}
			}
		},

		onShareAppMessage() {
			let uid = this.userInfo.uid ? this.userInfo.uid : 0;
			return {
				title: '途安车服',
				path: '/pages/index/index?spid=' + uid
			};
		},
	}
}
</script>
<style lang="scss"
	scoped>
	.footer-placeholder {
		height: calc(98rpx + constant(safe-area-inset-bottom));
		height: calc(98rpx + env(safe-area-inset-bottom));
		height: 98rpx;
	}

	.user-page {
		padding-bottom: calc(100rpx + constant(safe-area-inset-bottom));
		padding-bottom: calc(100rpx + env(safe-area-inset-bottom));
		padding-bottom: 100rpx;
	}

	.copy_right {
		text-align: center;
		color: #cccccc;
		font-size: 22rpx;
		margin-top: 40rpx;

		.copyRightImg {
			width: 219rpx;
			height: 74rpx;
			margin: 16rpx auto;
			display: block;
		}

		.support {
			width: 219rpx;
			height: 74rpx;
			margin: 54rpx auto;
			display: block;
		}

		.copyRightText {
			margin-top: 0rpx;
			color: #cccccc;
			font-size: 20rpx;
			margin-bottom: 20rpx;
		}
	}

	.tab-box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 16rpx 24rpx 20rpx;

		.longItem {
			display: inline-block;
			text-align: center;
			margin-right: 30rpx;
			position: relative;
			font-weight: 400;
			line-height: 56rpx;
			font-size: 30rpx;
			color: rgba(40, 40, 40, var(--un-text-opacity));

			&:last-child {
				margin-right: 0;
			}

			&.click {
				font-weight: bold;

				&::after {
					position: absolute;
					content: '';
					width: 36rpx;
					height: 30rpx;
					border: 2px solid var(--view-theme);
					border-left: 2px solid transparent !important;
					border-top: 2px solid transparent !important;
					border-right: 2px solid transparent !important;
					border-radius: 50%;
					left: 50%;
					bottom: -6rpx;
					margin-left: -24rpx;
				}
			}
		}
	}

	.mp-header {
		z-index: 99;
		position: fixed;
		//position: relative;
		left: 0;
		top: 0;
		width: 100%;

		.title {
			height: 43px;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 34rpx;
			font-weight: bold;
			line-height: 1;
		}
	}

	.data-tip {
		margin: 20rpx;
		padding: 20rpx 34rpx;
		background-color: #ffffff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-radius: 16rpx;
		font-size: 26rpx;

		.l {
			display: flex;
			align-items: center;

			.iconfont {
				font-size: 56rpx;
				margin-right: 20rpx;
				color: var(--view-theme);
			}
		}

		.l-txt {
			.l-1 {
				font-weight: bold;
			}

			.l-2 {
				color: #999999;
				margin-top: 6rpx;
			}
		}

		.r {
			padding: 14rpx 26rpx;
			border-radius: 30rpx;
			color: #ffffff;
			background-color: var(--view-theme);
		}
	}

	.badge-box {
		position: absolute;
		top: 0;
		right: -10rpx;
		background-color: #dd524d;
		border-radius: 50%;
		width: 16rpx;
		height: 16rpx;
	}
</style>